--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  6_SingleRestrictions_regPrep.log
  log type:  text
 opened on:  16 Apr 2018, 10:33:27

. ***************************************************************************;
. * REGRESSION PREP ;
. ***************************************************************************;
. local beginTime "DateTime: $S_DATE $S_TIME";

. set more off ;

. set linesize 200 ;

. set mem 5g ;
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. cd "$dataDir" ;

. ***************************************************************************;
. * MERGE POLICY MEASURES, AND OTHER CONTROLS;
. ***************************************************************************;
. use cpsAfterTaxsim_singleRestrictions ;

. * CHILDREN ;
. gen children = min(qualChild,3) ;

. tab children ;

   children |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    291,032       60.35       60.35
          1 |     88,788       18.41       78.76
          2 |     63,930       13.26       92.01
          3 |     38,529        7.99      100.00
------------+-----------------------------------
      Total |    482,279      100.00

. * TAX - THESE USE CPS DATA ;
. sort year state children ;

. merge m:1 year state children using simulatedmeasures ;
(note: variable state was byte, now float to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        56,822
        from master                    56,699  (_merge==1)
        from using                        123  (_merge==2)

    matched                           425,580  (_merge==3)
    -----------------------------------------

. drop if _merge == 2;
(123 observations deleted)

. drop _merge children ;

. summ *SIV* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
fedEICSIV_~i |    425,580    690.5275    916.8834          0   3143.289
fedRegTaxS~i |    425,580    2073.317    461.9369   978.7578   2933.046
  ctcSIV_uni |    425,580    290.2534    565.3139          0   2395.467
  amtSIV_uni |    425,580           0           0          0          0
stEICSIV_uni |    425,580    36.45982    138.0049          0   1571.645
-------------+---------------------------------------------------------
stRegTaxSI~i |    425,580    648.6864    396.5467          0    2081.07
stCredSIV_~i |    425,580     59.7314    129.5552  -260.7329   1184.794
 afdcSIV_uni |    425,580    2239.126    3362.936          0   20072.68
fedEIC~82cps |    425,580    411.4333     536.287          0   1681.633
fedReg~82cps |    425,580    2952.981    1041.781   570.4361    4513.09
-------------+---------------------------------------------------------
ctcSIV_82cps |    425,580    153.2019    281.7447          0   991.6729
amtSIV_82cps |    425,580    .0225156    .1681162          0   4.677181
stEICSIV_8~s |    425,580    21.37232    80.16772          0   840.8169
stRegT~82cps |    425,580    810.8488    517.2646          0   2314.984
stCred~82cps |    425,580    59.21647    132.5052  -156.4005   1357.953
-------------+---------------------------------------------------------
afdcSIV_82~s |    425,580    891.9103    1550.483          0   13290.01
fedEIC~92cps |    425,580    469.1385    623.2171          0   1858.366
fedReg~92cps |    425,580    3558.779    1361.168   662.2939   5554.682
ctcSIV_92cps |    425,580    110.4854    204.8494          0   727.2305
amtSIV_92cps |    425,580    .0051487    .0326646          0   .4305427
-------------+---------------------------------------------------------
stEICSIV_9~s |    425,580    24.61563    92.62945          0   929.1832
stRegT~92cps |    425,580    944.3778    615.6379          0   2674.383
stCred~92cps |    425,580    57.91637    132.2586  -153.7278   1348.678
afdcSIV_92~s |    425,580    929.1217    1649.518          0   14000.67

. * MERGE THE MANY WAIVER VARIABLES ;
. sort state ;

. merge m:1 state using afdcwaivers ;

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                           482,279  (_merge==3)
    -----------------------------------------

. drop if _merge==2 ;
(0 observations deleted)

. drop _merge ;

. summ afdcwaiver* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
afdcwaiver~s |    297,815    1995.602    1.067174       1993       1997
afdcwaive~it |    303,266    1997.818    2.426581       1996       2012
afdcwaive~et |    344,480    1995.098    1.249412       1990       1997
afdcwaiver~i |    268,004    1995.127      1.2675       1993       1997
afdcwaiver~v |    309,525    1994.927     1.54939       1990       1997
-------------+---------------------------------------------------------
afdcwaiver~d |    380,543    1993.773    2.375597       1988       1997

. * TRANSFER PROGRAM PARAMETERS FROM UKPRC - NOT SIMULATED;
. sort year state ;

. merge m:1 year state using state_level_variables_from_UKPRC ;

    Result                           # of obs.
    -----------------------------------------
    not matched                        11,090
        from master                    11,090  (_merge==1)
        from using                          0  (_merge==2)

    matched                           471,189  (_merge==3)
    -----------------------------------------

. drop if _merge == 2 ;
(0 observations deleted)

. drop _merge ;

. summ state year pop emp unemp unempr gsp afdcmb2 afdcmb3 afdcmb4 
>         fsmb1 fsmb2 fsmb3 fsmb4 ssimb eitcmax0 eitcmax1 eitcmax2 
>         steitcr steitcref fedminwge stminwge ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
       state |    482,279    24.59953    14.60863          1         51
        year |    482,279     1997.43    10.05526       1979       2013
         pop |    471,189    1.01e+07     9614333     401851   3.83e+07
         emp |    471,189     4668389     4356616     170798   1.70e+07
       unemp |    471,189    340644.6    383885.7       8163    2267908
-------------+---------------------------------------------------------
      unempr |    471,189    6.359702    2.125606        2.3       17.4
         gsp |    471,189    361668.2      438637       4856    2202678
     afdcmb2 |    471,189    339.1455    134.3977         60        823
     afdcmb3 |    471,189    417.9688    161.1138         96        925
     afdcmb4 |    471,189    492.0788    186.7417        120       1028
-------------+---------------------------------------------------------
       fsmb1 |    471,189    129.5789    42.31187         63        319
       fsmb2 |    471,189     237.847    77.65999        115        585
       fsmb3 |    471,189    340.8754    111.2773        165        839
       fsmb4 |    471,189    432.9718    141.2866        209       1065
       ssimb |    471,189    493.8078    188.2936          0       1036
-------------+---------------------------------------------------------
    eitcmax0 |    471,189    255.0813    195.7707          0        487
    eitcmax1 |    471,189    1990.867    951.1957        500       3250
    eitcmax2 |    471,189    3074.588    1787.311        500       5372
     steitcr |    471,189    .0976848     2.49827          0        110
   steitcref |    471,189    .1738474    .3789786          0          1
-------------+---------------------------------------------------------
   fedminwge |    471,189    4.962835    1.345974        3.1       7.25
    stminwge |    471,189    5.037177     1.65421       1.25       9.19

. * MERGE ON FEDERAL POVERTY LINE ;
. *gen othersandchildren = min(famsize , 9);
. gen qualchild = min(qualChild , 8) ;

. gen othersandchildren = 1+qualchild;

. sort year othersandchildren qualchild ;

. merge m:1 year othersandchildren qualchild using FPL ;

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,314
        from master                    11,090  (_merge==1)
        from using                      1,224  (_merge==2)

    matched                           471,189  (_merge==3)
    -----------------------------------------

. drop if _merge ==2 ;
(1,224 observations deleted)

. drop _merge ;

. summ fpl if year == 1993 & othersandchildren==2 & qualchild == 1 ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |      2,279       10960           0      10960      10960

. replace fpl = 9960 if year == 1993 & othersandchildren==2 & qualchild == 1 ;
(2,279 real changes made)

. summ fpl if year == 1993 & othersandchildren==5 & qualchild == 3 ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |          0

. replace fpl = 17245 if year == 1993 & othersandchildren==5 & qualchild == 3 ;
(0 real changes made)

. summ fpl ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         fpl |    471,189    10456.19      4078.9       4284      45037

. drop qualchild ;

.  * MERGE IN HOUSING SUBSIDY - 1984 onward;
. replace year = year +1 ;
(482,279 real changes made)

. sort year serial pernum ;

. merge 1:1 year serial pernum using housing_sub_cps ;

    Result                           # of obs.
    -----------------------------------------
    not matched                     5,117,116
        from master                    56,699  (_merge==1)
        from using                  5,060,417  (_merge==2)

    matched                           425,580  (_merge==3)
    -----------------------------------------

. drop if _merge == 2;
(5,060,417 observations deleted)

. drop _merge ;

. replace year = year - 1 ;
(482,279 real changes made)

. gen houssub = f_houssub*12 ;
(56,699 missing values generated)

. gen schlunch = f_mv_sl ;
(56,699 missing values generated)

. summ f_houssub houssub;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   f_houssub |    425,580    16.57468    62.65695          0        600
     houssub |    425,580    198.8962    751.8834          0       7200

. * ADJUST VARIABLES THAT NEED IT FOR INFLATION. SOME ARE ALAREDAY DONE ;
. foreach dollar of varlist gsp afdcmb2 afdcmb3 afdcmb4 
>                 fsmb1 fsmb2 fsmb3 fsmb4 ssimb eitcmax0 eitcmax1 eitcmax2
>                 fedminwge stminwge fpl houssub schlunch {;
  2.         qui replace `dollar' = `dollar' * (232.957/cpi);
  3.         };

. ***************************************************************************;
. * MAKING VARIABLES ;
. ***************************************************************************;
. gen afdcmb = 0 ;

. replace afdcmb = afdcmb2 if qualChild == 1 ;
(88,788 real changes made, 1,677 to missing)

. replace afdcmb = afdcmb3 if qualChild == 2 ;
(63,930 real changes made, 1,426 to missing)

. replace afdcmb = afdcmb4 if qualChild >= 3 ;
(38,529 real changes made, 1,017 to missing)

. gen fsmb = 0 ;

. replace fsmb = fsmb1 if qualChild == 0 ;
(291,032 real changes made, 6,970 to missing)

. replace fsmb = fsmb2 if qualChild == 1 ;
(88,788 real changes made, 1,677 to missing)

. replace fsmb = fsmb3 if qualChild == 2 ;
(63,930 real changes made, 1,426 to missing)

. replace fsmb = fsmb4 if qualChild >= 3 ;
(38,529 real changes made, 1,017 to missing)

. gen minwage = fedminwge+stminwge ;
(11,090 missing values generated)

. *replace famsize = min(famsize,5) ;
. replace hhsize = min(hhsize-1-qualChild, 5)  ;
(482,279 real changes made)

. sort state year;

. by state year: gen oneobs = _n ;

. summ afdcmb3 if oneobs == 1 & year==1984, d ;

                           afdcmb3
-------------------------------------------------------------
      Percentiles      Smallest
 1%     215.2442       215.2442
 5%     284.7501        264.571
10%     367.7088       284.7501       Obs                  51
25%     517.9313        318.382       Sum of Wgt.          51

50%     719.7228                      Mean           722.4045
                        Largest       Std. Dev.      280.7619
75%     825.1027       1179.359
90%     1121.063       1186.085       Variance       78827.26
95%     1186.085       1188.327       Skewness       .5034909
99%      1560.52        1560.52       Kurtosis       3.238699

. gen temp = afdcmb3>r(mean) if year==1984;
(470,235 missing values generated)

. sort state;

. by state : egen afdcmb3GTmean = max(temp);

. tab afdcmb3GTmean ;

afdcmb3GTme |
         an |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    227,654       47.20       47.20
          1 |    254,625       52.80      100.00
------------+-----------------------------------
      Total |    482,279      100.00

. drop oneobs temp;

. foreach var in jobs limit asset medi prov child {;
  2.         gen byte wave_`var' = (year>=afdcwaiver`var');
  3.         replace wave_`var' = 0 if wave_`var'==. ;
  4.         gen byte waveXc_`var' = (wave_`var')*(qualChild>0) ;
  5.         };
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)

. gen byte anywave = (wave_jobs+wave_limit+wave_asset+wave_medi+wave_prov+wave_child)>0 ;

. gen byte anywaveXc = anywave*(qualChild>0) ;

. summ afdcwaiver* wave_* waveXc_* anywave anywaveXc;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
afdcwaiver~s |    297,815    1995.602    1.067174       1993       1997
afdcwaive~it |    303,266    1997.818    2.426581       1996       2012
afdcwaive~et |    344,480    1995.098    1.249412       1990       1997
afdcwaiver~i |    268,004    1995.127      1.2675       1993       1997
afdcwaiver~v |    309,525    1994.927     1.54939       1990       1997
-------------+---------------------------------------------------------
afdcwaiver~d |    380,543    1993.773    2.375597       1988       1997
   wave_jobs |    482,279     .365131    .4814674          0          1
  wave_limit |    482,279    .3345346     .471828          0          1
  wave_asset |    482,279    .4341118    .4956402          0          1
   wave_medi |    482,279    .3382046    .4730991          0          1
-------------+---------------------------------------------------------
   wave_prov |    482,279    .3884038    .4873877          0          1
  wave_child |    482,279    .5010979    .4999993          0          1
 waveXc_jobs |    482,279    .1570771    .3638738          0          1
waveXc_limit |    482,279     .139807    .3467871          0          1
waveXc_asset |    482,279    .1806506    .3847288          0          1
-------------+---------------------------------------------------------
 waveXc_medi |    482,279      .13673    .3435624          0          1
 waveXc_prov |    482,279      .16156    .3680471          0          1
waveXc_child |    482,279    .2043133    .4031993          0          1
     anywave |    482,279    .5526283    .4972231          0          1
   anywaveXc |    482,279    .2278038    .4194158          0          1

. egen minyear = rowmin(afdcwaiver*) ;
(63608 missing values generated)

. gen waiver1995 = 0 ;

. replace waiver1995 = 1 if minyear < 1995 & minyear!=. & minyear!=0;
(243,069 real changes made)

. tab waiver1995, missing;

 waiver1995 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |    239,210       49.60       49.60
          1 |    243,069       50.40      100.00
------------+-----------------------------------
      Total |    482,279      100.00

. drop minyear ;

. foreach a of numlist 24(4)52 {;
  2.         gen byte age_`a' = (age >= `a' & age <= `a'+3);
  3.         };

. summ age age_* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         age |    482,279    32.25502    8.260749         21         48
      age_24 |    482,279    .1864564    .3894749          0          1
      age_28 |    482,279    .1444268    .3515223          0          1
      age_32 |    482,279    .1249733     .330689          0          1
      age_36 |    482,279    .1161672    .3204256          0          1
-------------+---------------------------------------------------------
      age_40 |    482,279    .1124722    .3159469          0          1
      age_44 |    482,279    .1058329     .307624          0          1
      age_48 |    482,279    .0249669    .1560243          0          1
      age_52 |    482,279           0           0          0          0

. *table year children [aw=wtsupp], c(mean age) ;
. gen byte hgc_11 = (hgc < 12) ;

. foreach e in 12 13 16 17 {;
  2.         gen byte hgc_`e' = (hgc == `e') ;
  3.         };

. summ hgc hgc_* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         hgc |    482,279    13.13944    1.809551         11         17
      hgc_11 |    482,279    .1304535    .3368021          0          1
      hgc_12 |    482,279    .3308541    .4705211          0          1
      hgc_13 |    482,279    .3155974    .4647538          0          1
      hgc_16 |    482,279    .1611826    .3676997          0          1
-------------+---------------------------------------------------------
      hgc_17 |    482,279    .0619123    .2409964          0          1

. *table year children [aw=wtsupp], c(mean hgc) ;
. *table year children [aw=wtsupp], c(mean hgc_11) ;
. gen byte white = race == 100 ;

. gen byte hispanic = hispan!=0 ;

. *tabstat white hispanic [aw=wtsupp], by(year) s(mean) c(v) ;
. gen byte divorced = marst == 3 | marst == 4 ;

. foreach c of numlist 0(1)3 {;
  2.         gen cI`c' = qualChild == `c' ;
  3.         };

. replace cI3 = 1 if qualChild > 3 ;
(12,276 real changes made)

. summ cI* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
         cI0 |    482,279    .6034515    .4891812          0          1
         cI1 |    482,279    .1841009    .3875669          0          1
         cI2 |    482,279    .1325581    .3390969          0          1
         cI3 |    482,279    .0798894    .2711222          0          1

. *summ ;
. save singleWomen_singleRestrictions, replace ;
file singleWomen_singleRestrictions.dta saved

. */
> *;
. disp "`beginTime'" ;
DateTime: 16 Apr 2018 10:33:27

. disp "DateTime: $S_DATE $S_TIME";
DateTime: 16 Apr 2018 10:33:54

. log close ;
      name:  <unnamed>
       log:  6_SingleRestrictions_regPrep.log
  log type:  text
 closed on:  16 Apr 2018, 10:33:54
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
